﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DataGridRead
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            foreach (DataGridViewColumn column in dataGridView1.Columns)
            {
                textBox1.Text += "Column "+column.Index+": ";
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (row.Index < dataGridView1.Rows.Count - 1)
                        textBox1.Text += row.Cells[column.Index].Value + " ";
                }
                textBox1.Text += "\r\n";
            }
        }
    }
}
